package com.mxnet.chongjin.supoman.utils;

import android.content.Context;
import android.util.Log;

/**
 * author: Administrator
 * email: lcj270018655@163.com
 * date: 2018/5/25
 */

public class DpAndPxUtils {

    public static int dip2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

    /**
     * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
     */
    public static int px2dip(Context context, float pxValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        Log.i("scscsc", scale + "");
        return (int) (pxValue / scale + 0.5f);
    }
}
